//Event.h
//Header file for Event.cpp
//@author A0101038Y
//@class Event

#ifndef EVENT_H
#define EVENT_H
#include "entry.h"
#include <sstream>
#include <string>
#include "CommonEnum.h"

class Event :
	public Entry
{
	QDate _startDate;
	QTime _startTime;
	static const string MSG_OUTPUT;
	bool _statusCompleted;
	
public:
	static const int NUM_ATTRIBUTES=6;
	static const string TYPE_ENTRY;
	static const string STATUS_DONE;
	static const string STATUS_NOT_DONE;
	static const string STATUS_UNSPECIFIED;
	static const char* SEARCH_PLACEHOLDER;
	static const char* SEARCH_DATE_FORMAT;
	static const char* SEARCH_TIME_FORMAT;

	//This is the constructor for new Event.
	//Pre-req: 
	//Post-req: new Event with attributes passed from Tokenizer
	Event(void);

	//This is the constructor for Event 
	//Pre-req: Entry
	//Post-req: Event with attributes
	Event(const Entry*);

	//This is the constructor for Event loaded from .txt storage file
	//Pre-req: strings in storage file
	//Post-req: Event
	Event(string, QDate, QTime, QDate, QTime, bool);

	//This is the deconstructor for Event
	//Pre-req: NIL
	//Post-req: NIL
	~Event(void);

	//This function check whether Event is empty
	//Pre-req: NIL
	//Post-req: return boolean value
	bool isEmpty();

	//This function gets the start date of an event
	//Pre-req: NIL
	//Post-req: return start date in QDate format
	QDate getStartDate() const;

	//This function gets the start time of an event
	//Pre-req: NIL
	//Post-req: return start time in QTime format
	QTime getStartTime() const;

	//This function checks conflicting Event
	//Pre-req: Entry
	//Post-req: return boolean value
	bool isConflict(Entry*);

	//This function combine vector of strings to a single string for storing
	//Pre-req: NIL;
	//Post-req: return string of Event to be stored
	string toString();

	//This function loads strings from storage file to string in strings in format acceptable by Event.
	//Pre-req: strings
	//Post-req: Event
	static Event fromString(string);

	//This function gets the various private attributes of Entry to be used in Event.
	//Pre-req: Entry
	//Post-req: return boolean value
	bool operator==(Entry*);

	//This function sets an Event as "Done"
	//Pre-req: NIL
	//Post-req: return boolean value
	bool setDone();

	//This function gets the status of an event.
	//Pre-req: NIL
	//Post-req: return boolean value associated with status of an event
	bool getStatus() const;

	//This function checks whether an event is currently ongoing.
	//Pre-req: current date and time in QDateTime format.
	//Post-req: returns boolean value
	bool isOngoingOrNot(QDateTime = QDateTime::currentDateTime()) const; 

	//This function sets the start date
	//Pre-req: start date, caller (to indicate whether tokenizer or entries manager calls the setter function)
	//Post-req: NIL
	void setStartDate(QDate, CommonEnum::CALLER);

	//This function sets the start time
	//Pre-req: start time, caller (to indicate whether tokenizer or entries manager calls the setter function)
	//Post-req: NIL
	void setStartTime(QTime, CommonEnum::CALLER);

	//This function gets the status string
	//Pre-req: NIL
	//Post-req: NIL
	string getStatusString() const;

	//This function gets the entry type
	//Pre-req: NIL
	//Post-req: NIL
	string getEntryType() const;

	//This function searches the strings according to keyword
	//Pre-req: NIL
	//Post-req: return string
	string getSearchString() const;

	//This function gets the attribute count
	//Pre-req: NIL
	//Post-req: return integer
	int getAttributeCount() const;

	//This function sets default start and end date or time if attributes are missing in storage file
	//Pre-req: NIL
	//Post-req: NIL
	void setDefaultStartEndDateTime();

	//Enumeration of Status for Event
	enum STATUS_TYPE_EVENT{
		NOT_DONE, DONE
	};

	//This function send status event for Status Message Printing
	//Pre-req: status of event
	//Post-req: return string
	string sendStatusEvent(STATUS_TYPE_EVENT status) const;

	//This function corrects end Date and Time so that it is later of at the same time as Start Date and Time when End attributes are missing
	//Pre-req: date and time
	//Post-req: NIL
	void setDefaultEndEvent(QDate, QTime);

	//This function corrects start date and time so it is earlier or at the same time as end when start attributes are missing.
	//Pre-req: date and time
	//Post-req: NIL
	void changeDefaultToEndDateTimeEvent(QDate, QTime);

	//This function completes the missing end date or time attributes
	//pre-req: NIL
	//post-req: NIL
	void completeMissingEndDateTimeAttributes();

	//This function completes the missing start date or time attributes
	//pre-req: NIL
	//post-req: NIL
	void completeMissingStartDateTimeAttributes();

	//This function sets start date for floating event
	//Pre-req: caller identification (from tokenizer or entries manager), start date
	//Post-req: NIL
	void setFloatStartDate(QDate, CommonEnum::CALLER);

	//This function sets start time for floating event
	//Pre-req: caller identification (from tokenizer or entries manager), start time
	//Post-req: NIL
	void setFloatStartTime(QTime, CommonEnum::CALLER);

	//This function sets end date for floating event
	//Pre-req: caller identification (from tokenizer or entries manager), end date
	//Post-req: NIL
	void setFloatEndDate(QDate, CommonEnum::CALLER);

	//This function sets end time for floating event
	//Pre-req: caller identification (from tokenizer or entries manager), end time
	//Post-req: NIL
	void setFloatEndTime(QTime, CommonEnum::CALLER);

	//This function compares for inConflict function
	//Pre-req: int, int
	//Post-req: return boolean value
	bool endToNewEndSmaller(int, int);

	//This function compares for inConflict function
	//Pre-req: int, int
	//Post-req: return boolean value
	bool newEndToEndSmaller(int, int);

	//This function corrects invalid edit where end date or time is earlier than start date or time (for start date or time edit)
	//Pre-req: Caller identification (tokenizer or entries manager, old date and old time)
	//Post-req: NIL
	void correctStartDateTimeValid(CommonEnum::CALLER, QDate, QTime);

	//This function reverts the invalid changes made
	//Pre-req: old date and old time
	//Post-req: NIL
	void revertInvalidEditStartDateTime(QDate, QTime);

	//This function sets the name (unused)
	//Pre-req: string
	//Post-req: NIL
//	void setName(string);
};

#endif